package com.pms.controller;

import com.pms.dto.PaymentPageQueryDTO;
import com.pms.dto.PaymentSaveDTO;
import com.pms.dto.PaymentUpdateDTO;
import com.pms.result.PageResult;
import com.pms.result.Result;
import com.pms.service.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "缴费相关接口")
@RestController
@RequestMapping("/payment")
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @ApiOperation("新增缴费信息")
    @PostMapping("/save")
    public Result<String> save(@RequestBody PaymentSaveDTO paymentSaveDTO){
        log.info("新增缴费信息,{}",paymentSaveDTO);
        paymentService.save(paymentSaveDTO);
        return Result.success();
    }

    @ApiOperation("缴费信息分页查询")
    @GetMapping("/page")
    public Result<PageResult> page(PaymentPageQueryDTO paymentPageQueryDTO){
        log.info("缴费信息分页查询,{}",paymentPageQueryDTO);
        PageResult pageResult=paymentService.page(paymentPageQueryDTO);
        return Result.success(pageResult);
    }

    @ApiOperation("修改缴费信息")
    @PutMapping("/update")
    public Result<String> update(@RequestBody PaymentUpdateDTO paymentUpdateDTO){
        log.info("修改缴费信息,{}",paymentUpdateDTO);
        paymentService.update(paymentUpdateDTO);
        return Result.success();
    }

    @ApiOperation("删除缴费信息")
    @DeleteMapping("/delete")
    public Result<String> deleteBatch(@RequestParam List<Integer> ids){
        log.info("删除缴费信息,{}",ids);
        paymentService.deleteBatch(ids);
        return Result.success();
    }
}
